class Solution {
public:
    bool isCompleteTree(TreeNode* root) {
        bool flag = true;
        queue<TreeNode*> q;
        q.push(root);
        while (!q.empty()) {
            int sz = q.size();
            for (int i = 0; i < sz; i++) {
                TreeNode* cur = q.front();
                q.pop();
                if (cur == nullptr) flag = false;
                else {
                    if (flag == false) return false;
                    q.push(cur->left);
                    q.push(cur->right);
                }
            }
        }
        return true;
    }
};